import json

from selenium import webdriver

class utils:
    imp = None
    tmp = None

    # 获取浏览器驱动对象，并进行IHML网址请求
    @classmethod
    def get_ihml(cls):
        if cls.imp is None:
            cls.imp = webdriver.Edge()
            cls.imp.maximize_window()
            cls.imp.get("https://ihrm-java.itheima.net/#/login")
        return cls.imp

    #进行退出操作
    @classmethod
    def quit_ihml(cls):
        if cls.imp != None:
            cls.get_ihml().quit()
            cls.imp = None

    # 获取浏览器驱动对象，并进行tpshop网址请求
    @classmethod
    def get_tp(cls):
        if cls.tmp is None:
            cls.tmp = webdriver.Edge()
            cls.tmp.maximize_window()
            cls.tmp.get("http://localhost:81/index.php")
        return cls.tmp

    #进行退出操作
    @classmethod
    def quit_tp(cls):
        if cls.tmp != None:
            cls.get_tp().quit()
            cls.tmp = None

def logs(fills):
    # 打开文件
    with open(fills, encoding="utf-8") as f:
        case_date = json.load(f)
    # 创建空列表
    list_date = []
    for case in case_date.values():
        list_date.append(tuple(case.values()))
    return list_date